var DAO = require('./DAO')
var evaluateuserDAO = {
    insertEvaluate:function(evaluate,callback){
        DAO('insert into evaluate(evaluateTime,content,grade) values(now(),?,?)',[evaluate.content,evaluate.grade],function(err,results){
            if(err){
                console.log(err)
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    delEvaluate:function(evaluateID,callback){
        DAO('delete from evaluate where evaluateID = ?',evaluateID,function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    selEvaluate:function(callback){
        DAO('select * from evaluate',null,function(err,results){
            if(err){
                console.log(err)
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    selOneEvaluate:function(tradeID,callback){
        DAO('select * from evaluate where tradeID = ?',tradeID,function(err,results){
            if(err){
                console.log(err)
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    insertbackevaluate:function(replyeval,callback){
        DAO('insert into replyeval(replycontent,replyTime,userID,evaluateID) values(?,now(),?,?)',[replyeval.replycontent,replyeval.userID,replyeval.evaluateID],function(err,results){
            if(err){
                console.log(err)
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    delbackevaluate:function(replyID,callback){
        DAO('delete from replyeval where replyID = ?',replyID,function(err,results){
            if(err){
                console.log(err)
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    selbackevaluate:function(evaluateID,callback){
        DAO('select * from replyeval where evaluateID = ?',evaluateID,function(err,results){
            if(err){
                console.log(err)
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
}
module.exports = evaluateuserDAO